package com.wicket.okrapp.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wicket.okrapp.base.service.MOmsAppraiserWeightSetDetailService;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.common.util.CommonFunctionHelper;
import com.wicket.okrapp.dal.mapper.mbg.OmsAppraiserWeightSetDetailMapper;
import com.wicket.okrapp.dal.po.mbg.OmsAppraiserWeightSetDetail;
import com.wicket.okrapp.base.service.dto.req.*;
//import com.wicket.okrapp.base.service.dto.res.*;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ：
 * @since 2022/1/19 15:39
 *
 *
 * @version 1.0
 */
@Service
public class MOmsAppraiserWeightSetDetailServiceImpl
  extends ServiceImpl<OmsAppraiserWeightSetDetailMapper, OmsAppraiserWeightSetDetail>
  implements MOmsAppraiserWeightSetDetailService {

  @Autowired
  OmsAppraiserWeightSetDetailMapper omsAppraiserWeightSetDetailMapper;
/**
   * 3-3-15新增评价人权重设置明细[3564]
   * gen by moon at 10/10/2022, 1:27:20 AM
   */
 @Trace(operationName = "3-3-15新增评价人权重设置明细")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  String  addAppraiserWsetDetail(OmsAppraiserWeightSetDetail omsAppraiserWeightSetDetail) {
     omsAppraiserWeightSetDetail.setAppraiserWeightSetDetailId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
omsAppraiserWeightSetDetail.setBatchEndtTime(CommonFunctionHelper.getFutureTime());//FUTURE_CURRENT_TIME
omsAppraiserWeightSetDetail.setIsUpdate("TRUE");
omsAppraiserWeightSetDetail.setUpdateStatus("NEW");
omsAppraiserWeightSetDetail.setArchivngType("NOT_ARCHIVE");
omsAppraiserWeightSetDetail.setIsEditing("TRUE");
omsAppraiserWeightSetDetail.setIsArchive("FALSE");
omsAppraiserWeightSetDetail.setSubjectLifeCycle("EDITING");
omsAppraiserWeightSetDetail.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
omsAppraiserWeightSetDetail.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
omsAppraiserWeightSetDetail.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
omsAppraiserWeightSetDetail.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
omsAppraiserWeightSetDetail.setIsValid("FALSE");
omsAppraiserWeightSetDetail.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
omsAppraiserWeightSetDetail.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
     if(super.save(omsAppraiserWeightSetDetail)){
        return omsAppraiserWeightSetDetail.getAppraiserWeightSetDetailId();
     }else {
        return "-1";
     }
    
  }
/**
   * 3-3-14批量删评价人权重设置明细[4222]
   * gen by moon at 10/10/2022, 1:27:21 AM
   */
 @Trace(operationName = "3-3-14批量删评价人权重设置明细")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  batchDeleteAppraiserWsetDetail(List<String> reqDto) {
     
          if(reqDto==null || reqDto.size()==0){
            return false;
          }
          
          return super.removeByIds(reqDto);
  }
/**
   * 3-3-14查询评价人权重设置明细列表[3269]
   * gen by moon at 10/10/2022, 1:27:19 AM
   */
 @Trace(operationName = "3-3-14查询评价人权重设置明细列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<OmsAppraiserWeightSetDetail>  queryAppraiserWsetDetailList(QueryAppraiserWsetDetailListReq reqDto) {
     
        try {
            QueryWrapper<OmsAppraiserWeightSetDetail> queryWrapper = new QueryWrapper<>();
            
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsAppraiserWeightSetDetail.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsAppraiserWeightSetDetail.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsAppraiserWeightSetDetail.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<OmsAppraiserWeightSetDetail>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }

}

